package leetcode

import "math"

/*
 * @lc app=leetcode.cn id=121 lang=golang
 *
 * [121] 买卖股票的最佳时机
 */

// @lc code=start
func maxProfit1(prices []int) int {
	min := math.MaxInt64
	ret := 0
	for _, v := range prices {
		if v > min {
			dif := v - min
			if dif > ret {
				ret = dif
			}
		} else {
			min = v
		}
	}
	return ret
}
// @lc code=end

